#!/usr/bin/env php
<?php

$worker = new GearmanWorker();
$worker->setTimeout(3000);
$worker->addServer('127.0.0.1', 4730);
$worker->addFunction('reverse', 'reverse_callback');

while (@$worker->work() ||
       $worker->returnCode() == GEARMAN_TIMEOUT)
{
  # This will after each job or the three second timeout
  print "Waiting for next job...\n";
}

print "Worker Error: " . $worker->error() . "\n";

function reverse_callback($job)
{
  return strrev($job->workload());
}

?>
